<?php

namespace App\EventSubscriber;

use App\Entity\AdminUserGroup;
use App\Event\AdminUserGroupRemoveEvent;
use App\Utils\Helper\GetterHelper;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

/**
 * 用户组删除事件订阅
 * Class AdminUserGroupRemoveSubscriber
 * @package App\EventSubscriber
 */
class AdminUserGroupRemoveSubscriber implements EventSubscriberInterface {
    /**
     * @inheritDoc
     */
    public static function getSubscribedEvents () {
        return [
            AdminUserGroupRemoveEvent::NAME => [
                ['updateCache', 10],
            ],
        ];
    }

    /**
     * 更新缓存
     * @param AdminUserGroupRemoveEvent $event
     */
    public function updateCache (AdminUserGroupRemoveEvent $event) {
        GetterHelper::getEntityManager()->getRepository(AdminUserGroup::class)->getAuthSignsById($event->getAdminUserGroupId());
    }

}